from direct.showbase.DirectObject import DirectObject
class Key(DirectObject):
	def __init__(self,keystring,action=None):
		self.pressed=False
		if not action:
			self.accept(keystring+"-up",self.key_up_action)
			self.accept(keystring,self.key_action)
		else:
			self.accept(keystring, action)
	def key_up_action(self):
		self.pressed=False
	def key_action(self):
		self.pressed=True
	def isPressed(self):
		return self.pressed
		